package com.hzqy.service.statistics;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;

import com.hzqy.persistence.dao.statistics.CpDao;
import com.hzqy.service.core.GenericServiceBean;
import com.hzqy.web.vo.PmsUserVo;
import com.hzqy.web.vo.StatDataCpVo;

@Service
public class CpServiceBean extends GenericServiceBean<PmsUserVo, CpDao, Integer>{
	private static final long serialVersionUID = 1L;
	protected final Logger LOG = LoggerFactory.getLogger(getClass());
	
	@Resource
	private CpDao cpDao;
	
	@Override
	public CpDao getEntityDao() {
		return cpDao;
	}
	public Map<String,Object> selectCpList(StatDataCpVo statDataCpVo, int curPage,int pageSize) {
		Map<String,Object> map = new HashMap<String, Object>();
		Integer rowCount = cpDao.selectCpCount(statDataCpVo);
		map.put("total", rowCount);
		if(rowCount > 0 && curPage > 0 && pageSize > 0) {
			map.put("firstResult", (curPage-1)*pageSize);
			map.put("maxResults", pageSize);
			map.put("f_sdc_orgid", statDataCpVo.getF_sdc_orgid());
			map.put("f_sdc_orgids", statDataCpVo.getF_sdc_orgids());
			map.put("f_sdc_orgname", statDataCpVo.getF_sdc_orgname());
			map.put("f_sdc_type", statDataCpVo.getF_sdc_type());
			map.put("f_sdc_resolution", statDataCpVo.getF_sdc_resolution());
			map.put("beginDate", statDataCpVo.getBeginDate());
			map.put("endDate", statDataCpVo.getEndDate());
			map.put("monthDate", statDataCpVo.getMonthDate());
			map.put("weekDate", statDataCpVo.getWeekDate());
			map.put("f_sdc_productid", statDataCpVo.getF_sdc_productid());
			List<StatDataCpVo> results = cpDao.selectCpList(map);
			map.put("rows", results);
		} else {
			map.put("rows", new ArrayList<StatDataCpVo>());
		}
		return map;
	}
	public Map<String, Object> selectExcelCpList(
			StatDataCpVo statDataCpVo) {
		Map<String,Object> map = new HashMap<String, Object>();
		Integer rowCount = cpDao.selectCpCount(statDataCpVo);
		map.put("total", rowCount);
		if(rowCount > 0) {
			map.put("f_sdc_orgid", statDataCpVo.getF_sdc_orgid());
			map.put("f_sdc_orgids", statDataCpVo.getF_sdc_orgids());
			map.put("f_sdc_orgname", statDataCpVo.getF_sdc_orgname());
			map.put("f_sdc_type", statDataCpVo.getF_sdc_type());
			map.put("f_sdc_resolution", statDataCpVo.getF_sdc_resolution());
			map.put("beginDate", statDataCpVo.getBeginDate());
			map.put("endDate", statDataCpVo.getEndDate());
			map.put("monthDate", statDataCpVo.getMonthDate());
			map.put("weekDate", statDataCpVo.getWeekDate());
			map.put("f_sdc_productid", statDataCpVo.getF_sdc_productid());
			List<StatDataCpVo> results = cpDao.selectCpExcelList(map);
			map.put("rows", results);
		} else {
			map.put("rows", new ArrayList<StatDataCpVo>());
		}
		return map;
	}

	
	
}